﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Interfaces;
using Controller;

namespace GUI
{
    public partial class frmFaerdigmeldScooter : Form
    { 
        OrdreController oc = new OrdreController();
        List<Iordre> ordreliste = null;

        public frmFaerdigmeldScooter()
        {
            
            InitializeComponent();
        }

        private void frmFaerdigmeldScooter_Load(object sender, EventArgs e)
        {
            
            ordreliste = oc.HentUafsluttedeOrdrer();

            foreach (Iordre item in ordreliste)
            {
                cmbOrdre.Items.Add(item.Ordrenummer.ToString());
            }
            
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbOrdre.SelectedIndex >= 0)
            {
                btnFaerdigmeld.Enabled = true;
            }
            else
            {
                btnFaerdigmeld.Enabled = false;
            }
        }

        private void btnFaerdigmeld_Click(object sender, EventArgs e)
        {
            DateTime slutdato = DateTime.Now;
            int nummerIListe = cmbOrdre.SelectedIndex;
            Iordre valgtOrdre;
            valgtOrdre = ordreliste[nummerIListe];
            KundeController kc = new KundeController();
            Ikunde kunde = kc.hentKunde(valgtOrdre.Kundenummer);
            int mobilnummer = Convert.ToInt32(kunde.Tlf);
            oc.FaerdigmeldOrdre(slutdato, valgtOrdre, mobilnummer);
            
            this.Close();
        }
    }
}
